home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
utility
/
252
/
dskpcsrc
/
deskpac.mod
< prev
next >
Wrap
Text File
|
1988-02-13
|
6KB
|
211 lines
MODULE DeskPac;
(*$S-,$T- turn off stack and range checking *)
(* IMPORT GEMError; -- Only needed if main app... *)
(* IMPORT GEMX; -- Only needed if main app... *)
FROM SYSTEM IMPORT SETREG, ADR, ADDRESS;
IMPORT GEMAESbase;
IMPORT AESApplications;
IMPORT AESEvents;
IMPORT AESForms;
IMPORT AESMenus;
IMPORT AESGraphics;
IMPORT AESResources;
IMPORT AESWindows;
IMPORT Text;
IMPORT Configuration;
IMPORT Resource;
IMPORT Screen;
IMPORT Event;
IMPORT Clock;
CONST
StackSize = 10000;
Keyboard = 0; (* Event Flags *)
Button = 1;
Mouse1 = 2;
Mouse2 = 3;
Message = 4;
Timer = 5;
ResourceLoadFailed =
"[3][ The DeskPac resource file | was not found. The DeskPac | tools are disabled. ][ OK ]";
NoLowResLine1 = "[3][ DeskPac requires that the | screen be in either Medium |";
NoLowResLine2 = " or High Resolution. The | DeskPac tools are disabled. ][ OK ]";
Failed = 0;
Erase = 0;
Display = 1;
VAR
Stack : ARRAY [0..StackSize] OF CARDINAL;
ExitButton : INTEGER;
AccessoryActive : BOOLEAN;
MsgBuffer : ARRAY [0..7] OF INTEGER;
WhichEvent : BITSET;
MouseCoordinate : Screen.PixelCoordinate;
MouseButton : INTEGER;
ModifierKey : INTEGER;
Key : INTEGER;
Clicks : INTEGER;
WindowId : INTEGER;
WhichMessage : INTEGER;
NotUsed : INTEGER;
Events : INTEGER;
Buffer : ARRAY [0..160] OF CHAR;
Success : BOOLEAN;
(* MenuAddress : ADDRESS; -- Only needed if main app... *)
(* BombOff : GEMX.ErrorProcessorType; -- Only needed if main app... *)
(* Only needed if main app...
PROCEDURE SaveTheWorld;
BEGIN
AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
AESApplications.ApplExit;
BombOff;
END SaveTheWorld;
*)
BEGIN
SETREG ( 15, ADR ( Stack[StackSize] ) ); (* If main app, then comment out this line *)
(* Only needed if main app...
BombOff := GEMX.ErrorProcessor;
GEMX.ErrorProcessor := SaveTheWorld;
*)
(*---- Initialize application --------------------------------------*)
Resource.ApplicationId := AESApplications.ApplInitialise ();
Event.AccessoryMenuId := AESMenus.MenuRegister ( (* If main app, then comment *)
Resource.ApplicationId, " DeskPac Plus " ); (* ...out these two lines. *)
Screen.Open ();
Configuration.LoadDefault;
(*---- Load the DeskPac resource file -------------------------------*)
IF Screen.Resolution = Screen.LowRes THEN
Text.Assign ( NoLowResLine1, Buffer );
Success := Text.ConcatString ( Buffer, NoLowResLine2, Buffer );
ExitButton := AESForms.FormAlert ( 1, Buffer );
AccessoryActive := FALSE;
Events := GEMAESbase.MesageEvent;
ELSE
IF Screen.Resolution = Screen.MediumRes THEN
AESResources.ResourceLoad ( Configuration.ColorResource );
ELSE
AESResources.ResourceLoad ( Configuration.MonochromeResource );
END;
IF GEMAESbase.AESCallResult = Failed THEN
ExitButton := AESForms.FormAlert ( 1, ResourceLoadFailed );
AccessoryActive := FALSE;
Events := GEMAESbase.MesageEvent;
ELSE
AccessoryActive := TRUE;
Events :=
GEMAESbase.KeyboardEvent +
GEMAESbase.ButtonEvent +
GEMAESbase.MesageEvent +
GEMAESbase.Mouse1Event + (* 6/6/87 - SMN *)
GEMAESbase.TimerEvent;
Event.Initialize;
(* Only needed if main app...
AESResources.ResourceGetAddr ( GEMAESbase.RTree, Resource.MENU, MenuAddress );
AESMenus.MenuBar ( MenuAddress, 1 );
*)
END;
END;
(*---- Process events from the user --------------------------------*)
AESGraphics.GrafMouse ( GEMAESbase.Arrow, NIL );
LOOP
WhichEvent := BITSET (AESEvents.EventMultiple (
Events,
2, (* Clicks *)
1, (* Monitor Left Mouse Button *)
1, (* Wait for key pressed *)
0, 0, 50, 640, 10, (* 6/6/87 - SMN *)
(* The above box serves no purpose other than waking up the *)
(* accessory ( I hope! ). We wont even process the event. *)
(* This kludge is necessitated bacause of the problems with *)
(* missing timer events from GEM. *)
0, 0, 0, 0, 0, (* Ignore Mouse Box2 *)
ADR (MsgBuffer),
Clock.TimerResolution, 0,
MouseCoordinate.X,
MouseCoordinate.Y,
MouseButton,
ModifierKey,
Key,
Clicks ));
AESWindows.WindowUpdate ( GEMAESbase.BeginUpdate );
AESWindows.WindowGet (
0,
GEMAESbase.Top,
WindowId,
NotUsed, NotUsed, NotUsed );
IF AccessoryActive THEN
Event.ProcessTimer;
END;
IF Message IN WhichEvent THEN
(* Only needed if main app...
IF MsgBuffer[0] = GEMAESbase.MenuSelected THEN
IF MsgBuffer[4] = Resource.MAIN THEN
MsgBuffer[0] := GEMAESbase.AccessoryOpen;
MsgBuffer[4] := Event.AccessoryMenuId;
Event.ProcessMessage ( WindowId, MsgBuffer );
ELSIF MsgBuffer[4] = Resource.QUIT THEN
EXIT;
END;
*)
IF AccessoryActive THEN
WindowId := MsgBuffer [3];
Event.ProcessMessage ( WindowId, MsgBuffer );
ELSIF MsgBuffer[0] = GEMAESbase.AccessoryClose THEN
(* Ignore the event *)
ELSE
ExitButton := AESForms.FormAlert ( 1, ResourceLoadFailed );
END;
END;
IF Button IN WhichEvent THEN
IF AccessoryActive THEN
Event.ProcessButton ( WindowId, MouseButton, ModifierKey, Clicks );
END;
END;
IF Keyboard IN WhichEvent THEN
IF AccessoryActive THEN
Event.ProcessKey ( WindowId, Key, ModifierKey );
END;
END;
AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
END (* LOOP *);
(* Only needed if main app...
AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
AESApplications.ApplExit;
*)
END DeskPac.